package com.reny.ll.git.base_logic

import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.reny.ll.git.mvvm.BaseViewModel
import com.reny.ll.git.mvvm.MvvmFragment
import org.kodein.di.DI
import org.kodein.di.DIAware
import org.kodein.di.android.x.closestDI
import org.kodein.di.diContext

abstract class MFragment<VB : ViewDataBinding>: MvvmFragment<VB>(), DIAware, IUseEventBus {

    protected val parentDI by closestDI()
    override val diContext = diContext<Fragment>(this)

    override val di by DI.lazy {
        extend(parentDI)
    }

    override val viewModel: BaseViewModel? = null

    override val delegateImp: MDelegateImp by lazy{
        MDelegateImp(this)
    }

    override fun getNoMoreTip(): String? = ""

    override fun useEventBus(): Boolean = false

    var needReload = false

    private fun reLoad(){
        if(!isFirstLoadPage && needReload){
            lazyLoad()
            needReload = false
        }
    }

    override fun onResume() {
        super.onResume()
        reLoad()
    }


}